import 'package:flutter/material.dart';
import 'package:get/get.dart';

class AppBarX extends StatelessWidget implements PreferredSizeWidget {
  final Widget? title;
  final double? elevation;
  final bool? centerTitle;
  final bool automaticallyImplyLeading;
  final Widget? leading;
  final void Function()? onLeadingTap;
  final List<Widget>? actions;
  const AppBarX(
      {super.key,
      this.title,
      this.onLeadingTap,
      this.elevation = 0,
      this.centerTitle = true,
        this.actions,
      this.automaticallyImplyLeading = false,
      this.leading});

  @override
  Widget build(BuildContext context) {
    return AppBar(
      title: title,
      centerTitle: centerTitle,
      elevation: elevation,
      automaticallyImplyLeading: automaticallyImplyLeading,
      actions: actions,
      leading: leading ??
          IconButton(
              onPressed: onLeadingTap ??
                  () {
                    Get.back();
                  },
              icon: Icon(Icons.arrow_back_ios_new)),
    );
  }

  @override
  Size get preferredSize => Size.fromHeight(kToolbarHeight);
}
